import request from '@/utils/request'

// 统一前缀
var prefix = '/fileService'

//条件查询文件
export function lookFile(file) {
  return request({
    url: `${prefix}/file`,
    method: 'GET',
    params: file,
  })
}

//上传文件返回ID
export function uploadFile(file) {
  return request({
    url: `${prefix}/file/upload`,
    method: 'POST',
    data: file,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  })
}

//分片上传
export function uploadFileCheck(file) {
  return request({
    url: `${prefix}/file/uploadChunk`,
    method: 'POST',
    data: file,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  })
}

//删除文件
export function deleteFile(ids) {
  return request({
    url: `${prefix}/file/delete`,
    method: 'DELETE',
    data: ids,
  })
}

export function download(id) {
  return request({
    url: `${prefix}/file/download`,
    method: 'GET',
    params: { id: id },
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
  })
}

//合并文件
export function mergeFile(formData) {
  return request({
    url: `${prefix}/file/merge`,
    timeout: 1 * 60 * 1000, //最大超时1小时
    method: 'POST',
    data: formData,
  })
}

//新增文件备注
export function addNote(file) {
  return request({
    url: `${prefix}/file/addNote`,
    method: 'POST',
    data: file,
  })
}

//根据ID查询文件信息
export function getOne(id) {
  return request({
    url: `${prefix}/file/getOne`,
    method: 'GET',
    params: { id: id },
  })
}

//根据ID查询文件信息
export function zipDownload(ids) {
  return request({
    url: `${prefix}/file/zipDownload`,
    method: 'POST',
    data: ids,
    timeout: 1 * 60 * 1000, //最大超时1小时
  })
}
